package cn.gdcp.demoa;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class MyFrontService extends Service {
    public MyFrontService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Intent intent = new Intent(MyFrontService.this,SecondActivity.class);
        PendingIntent pi = PendingIntent
                .getActivity(MyFrontService.this,0,intent,0);
        Notification notification = new Notification.Builder(MyFrontService.this)
                .setContentTitle("广交天气")
                .setContentText("晴转多云再转晴 还下着倾盆大雨")
                .setSmallIcon(R.mipmap.ic_launcher)
                .setWhen(System.currentTimeMillis())
                .setContentIntent(pi)
                .build();

        startForeground(1,notification);
    }
}
